<template>
    <view class="cu-card article shadow">
        <view class="cu-item shadow">
            <div flex-direction="row">
                <view class="title" style="display: inline-flex; width: 70%">
                    {{order.pay_time}}
                </view>
                <view class="title" style="display: inline-flex; width: 30%">
                    ¥{{order.amount}}
                </view>
            </div>
            <view class="content margin-bottom">
                {{order.order_content}}
            </view>
            <view class="content">
                <view class="desc">
                    <view class="flex">
                        <view class="cu-tag bg-green light sm round">
                            {{order.pay_channel}}
                        </view>
                        <view class="cu-tag light sm round" :class="order.status=='已开具'?'bg-green':'bg-red'">
                            发票开具状态：{{order.status}}
                        </view>
                    </view>
                    <view class="flex action justify-end" style="align-items: flex-end;">
                        <button 
                            class="cu-btn shadow" 
                            :class="order.status=='未开具'?'bg-blue':'bg-green'"
                            @click="clickInvoiceButton">
                            
                            {{order.status=='未开具'?'申请发票':'查看物流'}}
                        </button>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    name: 'invoicecard',
    props: {
        order: {
            type: Object,
            default: ""
        }
    },
    methods: {
        clickInvoiceButton: function() {
            if (this.order.status == '未开具') {
                uni.navigateTo({
                    url: 'applyinvoice/applyInvoice',
                    success: function() { console.log('ok'); },
                    fail: function() { console.log('fail'); },
                    complete: function() {}
                })
            }
            else {
                var para = 'com=' + this.order.express_channel + '&num=' + this.order.express_number;
                uni.navigateTo({
                    url: 'logistics/logistics?' + para,
                    success: function() { console.log('ok'); },
                    fail: function() { console.log('fail'); },
                    complete: function() {}
                })
            }
        }
    }
};
</script>
